package com.xaicode.learn.netty.tcpProtocol;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Locker xaicode@sina.com
 * @version 1.0
 * @date 2021/6/20 0020 9:49
 */
@Slf4j
public class NettyClientInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        final ChannelPipeline pipeline = ch.pipeline();

        // add decoder
        pipeline.addLast(new MessageDecoder());
        // add encoder
        pipeline.addLast(new MessageEncoder());
        // add self
        pipeline.addLast(new NettyClientHandler());
    }
}
